<?php
include("../libs/utils.func.php");
include("class.phpmailer.php");
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();
$mail->CharSet = "UTF8"; // 设置字符集编码

$mail->IsSMTP();
$mail->SMTPAuth   = false;                  // enable SMTP authentication
//$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "mta.net24.net.nz";      // sets GMAIL as the SMTP server
$mail->Port       = 25;                   // set the SMTP port for the GMAIL server

//$mail->Username   = "weida@nzios.ac.nz";
//$mail->Password   = "911911";

$mail->AddReplyTo("weida@nzios.ac.nz", "Weida Xue");

$mail->From       = "weida@nzios.ac.nz";
$mail->FromName   = "Weida Xue";

$mail->Subject    = "Student Application";

$body = (getParam('mail', null)) ? json_decode(getParam('mail', null)) : null;

$mail->Body       = '姓名: ' . $body->name . '<br>' .
                    '性别: ' . $body->gender . '<br>' .
                    '出生日期: ' . $body->birth . '<br>' .
                    '民族: ' . $body->ethnicity . '<br>' .
                    '地址１: ' . $body->address1 . '<br>' .
                    '地址２: ' . $body->address2 . '<br>' .
                    '地址３: ' . $body->address3 . '<br>' .
                    '户籍城市: ' . $body->city . '<br>' .
                    '学历: ' . $body->qualification . '<br>' .
                    '毕业院校: ' . $body->school . '<br>' .
                    '电话: ' . $body->phone . '<br>' .
                    '手机: ' . $body->mobile . '<br>' .
                    '电子邮件: ' . $body->email . '<br>' .
                    '申请课程: ' . $body->apply . '<br>' .
                    '申请入读时间: ' . $body->time . '<br>';

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap   = 50; // set word wrap

//$mail->MsgHTML($body);

$mail->AddAddress("application@nzios.ac.nz", "Jason Chan");

//$mail->AddAttachment("images/phpmailer.gif");             // attachment

$mail->IsHTML(false); // send as HTML

header('Content-Type: text/xml');
if(!$mail->Send()) {
  echo '<r v="0"/>';
} else {
  echo '<r v="1"/>';
}

?>
